﻿using System;
using System.Windows.Interop;
using System.Runtime.InteropServices;

namespace MimicAPI
{
    /// <summary>Improved version of MessageBox for Vista</summary>
    public static class TaskDialog
    {
        /// <summary>More information on : "http://pinvoke.net"</summary>
        [DllImport("comctl32.dll", EntryPoint = "TaskDialog", PreserveSig = false, CharSet = CharSet.Unicode)]
        static extern TaskDialogResult Pinvoke_TaskDialog(IntPtr hwndParent, IntPtr hInstance, string title, string mainInstruction,
                                                          string content, TaskDialogButtons buttons, TaskDialogIcon icon);

        /// <summary>This function requires version 6 of the Windows Common Controls DLL (ComCtl32.dll)</summary>
        public static TaskDialogResult Show(this System.Windows.Window wndParent, string title, string mainInstruction,
                                            string content, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            return Pinvoke_TaskDialog(wndParent == null ? IntPtr.Zero : new WindowInteropHelper(wndParent).Handle,
                                      IntPtr.Zero, title, mainInstruction, content, buttons, icon);
        }

        /// <summary>This function requires version 6 of the Windows Common Controls DLL (ComCtl32.dll)</summary>
        public static TaskDialogResult Show(string title, string mainInstruction, string content, TaskDialogButtons buttons, TaskDialogIcon icon)
        {
            return Show(null, title, mainInstruction, content, buttons, icon);
        }
    }
}
